package com.youhp.spire.xls.demo.Worksheets;

import com.spire.xls.*;

import java.awt.*;

public class SetTabColor {
    public static void main(String[] args) {
        String inputFile = "data/SetTabColor.xlsx";
        String outputFile = "output/SetTabColor_out.xlsx";

        //Create a workbook and load a file
        Workbook workbook = new Workbook();
        workbook.loadFromFile(inputFile);

        //Set the tab color of first sheet to be red
        Worksheet worksheet = workbook.getWorksheets().get(0);
        worksheet.setTabColor(Color.red);

        //Set the tab color of second sheet to be green
        worksheet = workbook.getWorksheets().get(1);
        worksheet.setTabColor(Color.gray);

        //Set the tab color of third sheet to be blue
        worksheet = workbook.getWorksheets().get(2);
        worksheet.setTabColor(Color.blue);

        //Save the Excel file
        workbook.saveToFile(outputFile, ExcelVersion.Version2010);
    }
}
